package com.dianhun.es.exhandler;


import com.dianhun.es.ex.GlobalEx;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author cyt
 * @create 2020-08-26 11:28
 */
@Slf4j
@ControllerAdvice
public class GlobalExHandler {

    @ExceptionHandler(Exception.class)
    @ResponseBody
    public String error(Exception e) {
        e.printStackTrace();
        return "执行了异常";
    }



    @ExceptionHandler(GlobalEx.class)
    @ResponseBody
    public String error(GlobalEx e) {
        e.printStackTrace();
        return "执行的自定义异常";
    }
}
